<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
// 
// 
// 
	// 截取字符串 例{$vo.title|subtext=10} 
	function subtext($text,$length=12)
	 {
	    	$text= mb_substr($text, 0, $length, 'utf8').'...';
	    	return $text;
	   
	    
	 }
	 function ifExist($data='')
	 {
		 if(empty($data))
		 {
			 echo '<literal><script>alert("没有相关数据");top.location.href="index";</script></literal>';//没有数据时提示并跳转
		 }
	 }
	 function zrJump($msg,$url)
	 {
		  echo '<literal><script>alert("$msg");top.location.href="$url";</script></literal>';//没有数据时提示并跳转
	 }

	 function get_imgurl($url,$cat=0){
    if(stripos($url,'http')!==false){
        //网络图片
        return $url;
    }elseif($url && stripos($url,'/')===false && stripos($url,'\\')===false){
       //头像
        return __ROOT__.'/data/upload/avatar/'.$url;
    }elseif(empty($url)){
        //$url为空
        if($cat==2){
            $imgurl='girl.jpg';
        }elseif($cat==1){
            $imgurl='headicon.png';
        }else{
            $imgurl='no_img.jpg';
        }
        return __ROOT__.'/public/img/'.$imgurl;
    }else{
        //本地上传图片
        return $url;
    }
}
